using GooglePlayGames;
using GooglePlayGames.BasicApi;
using Heyzap;
using UnityEngine;

public class AdsVideoController : MonoBehaviour
{
	private AdsVideoController singleton;

	private void Awake()
	{
		HeyzapAds.Start("6671feebbe7196703e67d2b7c341b467", 0);
		HZIncentivizedAd.Fetch();
		PlayGamesClientConfiguration configuration = new PlayGamesClientConfiguration.Builder().Build();
		PlayGamesPlatform.InitializeInstance(configuration);
		PlayGamesPlatform.Activate();
		if (singleton != null)
		{
			UnityEngine.Object.Destroy(base.gameObject);
			return;
		}
		singleton = this;
		Object.DontDestroyOnLoad(base.gameObject);
	}

	private void Start()
	{
		RequestInterstitial();
	}

	private void OnHideUnity(bool isGameShown)
	{
	}

	public static void LoadUnityAds()
	{
		HZIncentivizedAd.Fetch();
	}

	public static void RequestInterstitial()
	{
		HZInterstitialAd.Fetch();
	}

	public static void ShowAdFull()
	{
		HZInterstitialAd.Show();
		HZInterstitialAd.Fetch();
	}

	public static void ShowAds()
	{
		if (HZIncentivizedAd.IsAvailable())
		{
			HZIncentivizedAd.AdDisplayListener displayListener = delegate(string adState, string adTag)
			{
				if (adState.Equals("incentivized_result_complete"))
				{
					if (Application.systemLanguage == SystemLanguage.Vietnamese)
					{
						MNPopup mNPopup3 = new MNPopup("Chúc mừng", "Chúc mừng bạn đã nhận quà thành công!");
						mNPopup3.AddAction("Ok", delegate
						{
						});
						mNPopup3.AddDismissListener(delegate
						{
						});
						mNPopup3.Show();
					}
					else
					{
						MNPopup mNPopup4 = new MNPopup("Congratulations", "The Gift has been received successfully!");
						mNPopup4.AddAction("Ok", delegate
						{
						});
						mNPopup4.AddDismissListener(delegate
						{
						});
						mNPopup4.Show();
					}
					if (GameManager.BonusGift == 0)
					{
						if (GameManager.key_stage <= 10)
						{
							GameManager.TotalCoin += 1000;
						}
						else if (GameManager.key_stage > 10 && GameManager.key_stage <= 20)
						{
							GameManager.TotalCoin += 2000;
						}
						else if (GameManager.key_stage > 20 && GameManager.key_stage <= 30)
						{
							GameManager.TotalCoin += 3000;
						}
						else if (GameManager.key_stage > 30 && GameManager.key_stage <= 40)
						{
							GameManager.TotalCoin += 4000;
						}
						else if (GameManager.key_stage > 40 && GameManager.key_stage <= 50)
						{
							GameManager.TotalCoin += 5000;
						}
						else
						{
							GameManager.TotalCoin += 8000;
						}
					}
					else if (GameManager.key_stage <= 20)
					{
						GameManager.numberHealth += 2;
					}
					else if (GameManager.key_stage > 20 && GameManager.key_stage <= 30)
					{
						GameManager.numberHealth += 3;
					}
					else if (GameManager.key_stage > 30 && GameManager.key_stage <= 54)
					{
						GameManager.numberBigHealth += 2;
					}
					else
					{
						GameManager.numberBigHealth += 3;
					}
				}
				if (adState.Equals("incentivized_result_incomplete"))
				{
					if (Application.systemLanguage == SystemLanguage.Vietnamese)
					{
						MNPopup mNPopup5 = new MNPopup("Lỗi", "Không hoàn thành Video! Xin thử lại!");
						mNPopup5.AddAction("Ok", delegate
						{
						});
						mNPopup5.AddDismissListener(delegate
						{
						});
						mNPopup5.Show();
					}
					else
					{
						MNPopup mNPopup6 = new MNPopup("Opps", "Not completed Ads! Please try again!");
						mNPopup6.AddAction("Ok", delegate
						{
						});
						mNPopup6.AddDismissListener(delegate
						{
						});
						mNPopup6.Show();
					}
				}
			};
			HZIncentivizedAd.SetDisplayListener(displayListener);
			HZIncentivizedAd.Show();
			LoadUnityAds();
			return;
		}
		if (Application.systemLanguage == SystemLanguage.Vietnamese)
		{
			MNPopup mNPopup = new MNPopup("Lỗi", "Không thể nhận video. Xin quay lại sau!");
			mNPopup.AddAction("Ok", delegate
			{
			});
			mNPopup.AddDismissListener(delegate
			{
			});
			mNPopup.Show();
		}
		else
		{
			MNPopup mNPopup2 = new MNPopup("Opps", "Faild to load ads! Please try again later!");
			mNPopup2.AddAction("Ok", delegate
			{
			});
			mNPopup2.AddDismissListener(delegate
			{
			});
			mNPopup2.Show();
		}
		LoadUnityAds();
	}
}
